package org.feng.fxfront.pages;

import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;
import org.feng.api.sys.annotations.PageNodeKey;
import org.feng.fxfront.sys.PageNodeRender;
import org.feng.fxfront.util.StyleUtil;


/**
 * 主页
 *
 * @author feng
 */
@PageNodeKey(value = MainPage.PAGE_KEY, pageName = "主页面", order = -1)
public class MainPage implements PageNodeRender {

    public static final String PAGE_KEY = "main";

    @Override
    public Node render(Pane pane) {
        VBox vbox = new VBox();
        vbox.setMaxWidth(pane.getMaxWidth());
        vbox.setMaxHeight(pane.getMaxHeight());
        vbox.setAlignment(Pos.CENTER);
        Label mainLabel = new Label("主页面");
        StyleUtil.setFont(mainLabel, Color.BLACK, 30);
        vbox.getChildren().add(mainLabel);

        // 设置背景图
        Image image = new Image("/main_page_bg.png");
        BackgroundImage backgroundImage = new BackgroundImage(image, BackgroundRepeat.REPEAT, BackgroundRepeat.REPEAT, BackgroundPosition.DEFAULT, BackgroundSize.DEFAULT);
        Background background = new Background(backgroundImage);
        vbox.setBackground(background);

        return vbox;
    }
}
